import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:one_flutter/MyAppBar.dart';

class RouteButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: Center(
        child: RaisedButton(
          onPressed: () {
            _showReruenData(context);
          },
          child: Text('跳转详情'),
        )
      ),
    );
  }

  _showReruenData(BuildContext context) async{
    final result = await Navigator.push(
        context, MaterialPageRoute(builder: (context) => Details()));
    Scaffold.of(context).showSnackBar(SnackBar(content: Text('$result')));
  }
}

class Details extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: CommonBar(title: '详情页面,回传数据'),
      body: Center(
        child: Column(
          children: [
            RaisedButton(
                child: Text('详情数据1'),
                onPressed: () {
                  Navigator.pop(context, '返回的详情数据1');
                }),
            RaisedButton(
                child: Text('详情数据2'),
                onPressed: () {
                  Navigator.pop(context, '返回的详情数据2');
                }),
          ],
        ),
      ),
    );
  }
}
